package com.hiultra.archive.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.hiultra.archive.domain.ArchiveStorageBox;
import com.hiultra.archive.service.IArchiveStorageBoxService;
import com.hiultra.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hiultra.common.annotation.Log;
import com.hiultra.common.core.controller.BaseController;
import com.hiultra.common.core.domain.AjaxResult;
import com.hiultra.common.enums.BusinessType;

import com.hiultra.common.core.page.TableDataInfo;

/**
 * 档案入库档案盒Controller
 * 
 * @author ruoyi
 * @date 2024-07-22
 */
@RestController
@RequestMapping("/archive/storageBox")
public class ArchiveStorageBoxController extends BaseController
{
    @Autowired
    private IArchiveStorageBoxService archiveStorageBoxService;

    /**
     * 查询档案入库档案盒列表
     */
    @PreAuthorize("@ss.hasPermi('archive:storageBox:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArchiveStorageBox archiveStorageBox)
    {
        startPage();
        List<ArchiveStorageBox> list = archiveStorageBoxService.selectArchiveStorageBoxList(archiveStorageBox);
        return getDataTable(list);
    }

    /**
     * 导出档案入库档案盒列表
     */
    @PreAuthorize("@ss.hasPermi('archive:storageBox:export')")
    @Log(title = "档案入库档案盒", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArchiveStorageBox archiveStorageBox)
    {
        List<ArchiveStorageBox> list = archiveStorageBoxService.selectArchiveStorageBoxList(archiveStorageBox);
        ExcelUtil<ArchiveStorageBox> util = new ExcelUtil<ArchiveStorageBox>(ArchiveStorageBox.class);
        util.exportExcel(response, list, "档案入库档案盒数据");
    }

    /**
     * 获取档案入库档案盒详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive:storageBox:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(archiveStorageBoxService.selectArchiveStorageBoxById(id));
    }

    /**
     * 获取档案入库档案盒详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive:storageBox:query')")
    @GetMapping(value = "/selectArchiveStorageBoxByTaskId/{taskId}")
    public AjaxResult selectArchiveStorageBoxByTaskId(@PathVariable("taskId") String taskId)
    {
        List<ArchiveStorageBox> data = archiveStorageBoxService.selectArchiveStorageBoxByTaskId(taskId);
        return AjaxResult.success(data);
    }

    /**
     * 新增档案入库档案盒
     */
    @PreAuthorize("@ss.hasPermi('archive:storageBox:add')")
    @Log(title = "档案入库档案盒", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArchiveStorageBox archiveStorageBox)
    {
        return toAjax(archiveStorageBoxService.insertArchiveStorageBox(archiveStorageBox));
    }

    /**
     * 修改档案入库档案盒
     */
    @PreAuthorize("@ss.hasPermi('archive:storageBox:edit')")
    @Log(title = "档案入库档案盒", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArchiveStorageBox archiveStorageBox)
    {
        return toAjax(archiveStorageBoxService.updateArchiveStorageBox(archiveStorageBox));
    }

    /**
     * 删除档案入库档案盒
     */
    @PreAuthorize("@ss.hasPermi('archive:storageBox:remove')")
    @Log(title = "档案入库档案盒", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(archiveStorageBoxService.deleteArchiveStorageBoxByIds(ids));
    }
}
